package com.wkh.project.driver.controller;

import com.wkh.project.common.result.Result;
import com.wkh.project.driver.service.DriverInfoService;
import com.wkh.project.model.entity.driver.DriverSet;
import com.wkh.project.model.form.driver.DriverFaceModelForm;
import com.wkh.project.model.form.driver.UpdateDriverAuthInfoForm;
import com.wkh.project.model.vo.driver.DriverAuthInfoVo;
import com.wkh.project.model.vo.driver.DriverInfoVo;
import com.wkh.project.model.vo.driver.DriverLoginVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Tag(name = "司机API接口管理")
@RestController
@RequestMapping(value="/driver/info")
@SuppressWarnings({"unchecked", "rawtypes"})
public class DriverInfoController {
	@Resource
	private DriverInfoService driverInfoService;
	@Operation(summary = "司机端小程序登录")
	@GetMapping("/login/{code}")
	public Result<Long> login(@PathVariable String code){
		Long driverId = driverInfoService.login(code);
		return Result.ok(driverId);
	}

	@Operation(summary = "获取司机登录信息")
	@GetMapping("/getDriverLoginInfo/{driverId}")
	public Result<DriverLoginVo> getDriverLoginInfo(@PathVariable Long driverId) {
		return Result.ok(driverInfoService.getDriverLoginInfo(driverId));
	}

	@Operation(summary = "获取司机认证信息")
	@GetMapping("/getDriverAuthInfo/{driverId}")
	public Result<DriverAuthInfoVo> getDriverAuthInfo(@PathVariable Long driverId) {
		DriverAuthInfoVo driverAuthInfoVo = driverInfoService.getDriverAuthInfo(driverId);
		return Result.ok(driverAuthInfoVo);
	}

	@Operation(summary = "更新司机认证信息")
	@PostMapping("/updateDriverAuthInfo")
	public Result<Boolean> updateDriverAuthInfo(@RequestBody UpdateDriverAuthInfoForm updateDriverAuthInfoForm) {
		Boolean isSuccess = driverInfoService.updateDriverAuthInfo(updateDriverAuthInfoForm);
		return Result.ok(isSuccess);
	}
	@Operation(summary = "创建司机人脸模型")
	@PostMapping("/createDriverFaceModel")
	public Result<Boolean> createDriverFaceModel(@RequestBody DriverFaceModelForm driverFaceModelForm){
		Boolean isSuccess = driverInfoService.createDriverFaceModel(driverFaceModelForm);
		return Result.ok(isSuccess);
	}

	@Operation(summary = "获取司机设置信息")
	@GetMapping("/getDriverSet/{driverId}")
	public Result<DriverSet> getDriverSet(@PathVariable Long driverId) {
		return Result.ok(driverInfoService.getDriverSet(driverId));
	}

	@Operation(summary = "判断司机当日是否进行过人脸识别")
	@GetMapping("/isFaceRecognition/{driverId}")
	Result<Boolean> isFaceRecognition(@PathVariable("driverId") Long driverId) {
		return Result.ok(driverInfoService.isFaceRecognition(driverId));
	}

	@Operation(summary = "验证司机人脸")
	@PostMapping("/verifyDriverFace")
	public Result<Boolean> verifyDriverFace(@RequestBody DriverFaceModelForm driverFaceModelForm) {
		return Result.ok(driverInfoService.verifyDriverFace(driverFaceModelForm));
	}

	@Operation(summary = "更新接单状态")
	@GetMapping("/updateServiceStatus/{driverId}/{status}")
	public Result<Boolean> updateServiceStatus(@PathVariable Long driverId, @PathVariable Integer status) {
		return Result.ok(driverInfoService.updateServiceStatus(driverId, status));
	}

	@Operation(summary = "获取司机的基本信息")
	@GetMapping("/getDriverInfo/{driverId}")
	public Result<DriverInfoVo> getDriverInfo(@PathVariable Long driverId){
		return Result.ok(driverInfoService.getDriverInfo(driverId));
	}

	@Operation(summary = "获取司机OpenId")
	@GetMapping("/getDriverOpenId/{driverId}")
	public Result<String> getDriverOpenId(@PathVariable Long driverId) {
		return Result.ok(driverInfoService.getDriverOpenId(driverId));
	}
}

